/*******************************************************************************
 * Copyright (c) 2007 University of Oslo.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     University of Oslo - initial API and implementation
 *******************************************************************************/

package com.cea.papyrus.diagram.sequence.sedi.edit.command;

/**
 * Examines the margins for a (multicovering) interaction fragment. The margins
 * measure the space from the left edge of the fragment to the leftmost covered
 * lifeline and the space from the right edge of the fragment to the rightmost
 * covered lifeline.
 * 
 * <p>
 * The following attributes must be set before the command can run successfully:
 * </p>
 * <ul>
 * <li>Fragment
 * <li>EditPart
 * </ul>
 * 
 * <p>
 * When completed, the following attributes can be read to access the result:
 * </p>
 * <ul>
 * <li>LeftMargin
 * <li>RightMargin
 * </ul>
 * 
 * @author frankd@ifi.uio.no
 */
public class AnalyseFragmentMarginsCommand extends AbstractMarginCommand {

	private int[] margins;

	public int getLeftMargin() {
		return margins[0];
	}

	public int getRightMargin() {
		return margins[1];
	}

	@Override
	public void execute() {
		margins = this.getMargins(fragment);
	}

	@Override
	public void redo() {
		execute();
	}

	@Override
	public void dispose() {
		super.dispose();
		margins = null;
	}
}
